package test19.printstream;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class PrintWriter_ {
    public static void main(String[] args) throws IOException {
        //打印到显示器
        PrintWriter writer1 = new PrintWriter(System.out);
        writer1.print("hi，北京你好");
        writer1.close();

        //打印到文件中
        PrintWriter writer = new PrintWriter(new FileWriter("d:\\a.txt",true));
        writer.print("hi，北京你好");
        writer.close();
    }
}
